﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
    <Style x:Key="Style.TabItem" TargetType="{x:Type TabItem}">
        <Setter Property="Background" Value="{DynamicResource Brush.TabItem.Background}" />
        <Setter Property="BorderBrush" Value="{DynamicResource Brush.TabItem.Border}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Foreground" Value="{DynamicResource Brush.TabItem.Foreground}" />
        <Setter Property="Padding" Value="10,4" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Border 
                        x:Name="PART_Border" 
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}" 
                        BorderThickness="{TemplateBinding BorderThickness}" 
                        Margin="0,0,-1,0"
                        Padding="{TemplateBinding Padding}" 
                        SnapsToDevicePixels="True">
                        <ContentPresenter 
                            x:Name="PART_Content" 
                            ContentSource="Header" 
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                            TextBlock.Foreground="{Binding Foreground, RelativeSource={RelativeSource TemplatedParent}}"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Background" Value="{DynamicResource Brush.TabItem.Selected.Background}" />
                <Setter Property="BorderBrush" Value="{DynamicResource Brush.TabItem.Selected.Border}" />
                <Setter Property="BorderThickness" Value="1,1,1,0" />
                <Setter Property="Cursor" Value="Arrow" />
                <Setter Property="Foreground" Value="{DynamicResource Brush.TabItem.Selected.Foreground}" />
            </Trigger>
            <Trigger Property="IsSelected" Value="False">
                <Setter Property="Cursor" Value="Hand" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsSelected" Value="False"/>
                    <Condition Property="IsMouseOver" Value="True"/>
                </MultiTrigger.Conditions>
                <Setter Property="Background" Value="{DynamicResource Brush.TabItem.MouseOver.Background}" />
                <Setter Property="BorderBrush" Value="{DynamicResource Brush.TabItem.MouseOver.Border}" />
                <Setter Property="Foreground" Value="{DynamicResource Brush.TabItem.MouseOver.Foreground}" />
            </MultiTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="Style.TabControl.Horizontal" TargetType="{x:Type TabControl}">
        <Setter Property="Background" Value="{DynamicResource Brush.TabControl.Background}" />
        <Setter Property="BorderBrush" Value="{DynamicResource Brush.TabControl.Border}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="TabStripPlacement" Value="Top" />
        <Setter Property="ItemContainerStyle" Value="{StaticResource Style.TabItem}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <Grid 
                        ClipToBounds="True" 
                        KeyboardNavigation.TabNavigation="Local"
                        SnapsToDevicePixels="True">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" x:Name="RowDefinition0" />
                            <RowDefinition Height="*" x:Name="RowDefinition1" />
                        </Grid.RowDefinitions>
                        <TabPanel 
                            x:Name="PART_Panel"  
                            IsItemsHost="True" 
                            KeyboardNavigation.TabIndex="1"
                            Panel.ZIndex="1"/>
                        <Border 
                            Grid.Row="1"
                            x:Name="PART_Content" 
                            Background="{TemplateBinding Background}" 
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}" 
                            KeyboardNavigation.TabIndex="2" 
                            KeyboardNavigation.TabNavigation="Local" 
                            KeyboardNavigation.DirectionalNavigation="Contained"
                            Margin="0,-1,0,0"
                            Padding="{TemplateBinding Padding}">
                            <ContentPresenter 
                                x:Name="PART_SelectedContentHost" 
                                Content="{TemplateBinding SelectedContent}" 
                                ContentTemplate="{TemplateBinding SelectedContentTemplate}" 
                                ContentStringFormat="{TemplateBinding SelectedContentStringFormat}" 
                                ContentSource="SelectedContent"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="TabStripPlacement" Value="Bottom">
                            <Setter TargetName="PART_Panel" Property="Grid.Row" Value="1" />
                            <Setter TargetName="PART_Content" Property="Grid.Row" Value="0" />
                            <Setter TargetName="RowDefinition0" Property="Height" Value="*" />
                            <Setter TargetName="RowDefinition1" Property="Height" Value="Auto" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="Style.TabControl.Vertical" TargetType="{x:Type TabControl}">
        <Setter Property="Background" Value="{DynamicResource Brush.TabControl.Background}" />
        <Setter Property="BorderBrush" Value="{DynamicResource Brush.TabControl.Border}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="TabStripPlacement" Value="Left" />
        <Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style TargetType="{x:Type TabItem}" BasedOn="{StaticResource Style.TabItem}">
                    <Setter Property="Padding" Value="10,2"/>
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <Grid ClipToBounds="True" SnapsToDevicePixels="True" KeyboardNavigation.TabNavigation="Local">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition x:Name="ColumnDefinition0" />
                            <ColumnDefinition Width="0" x:Name="ColumnDefinition1" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" x:Name="RowDefinition0" />
                            <RowDefinition Height="*" x:Name="RowDefinition1" />
                        </Grid.RowDefinitions>
                        <TabPanel  
                            x:Name="PART_Panel" 
                            IsItemsHost="True"  
                            KeyboardNavigation.TabIndex="1"
                            Panel.ZIndex="1"/>
                        <Border 
                            Grid.Row="1"
                            x:Name="PART_Content" 
                            Background="{TemplateBinding Background}" 
                            BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="{TemplateBinding BorderThickness}"
                            KeyboardNavigation.TabIndex="2" 
                            KeyboardNavigation.TabNavigation="Local"
                            KeyboardNavigation.DirectionalNavigation="Contained"
                            Padding="{TemplateBinding Padding}">
                            <ContentPresenter 
                                x:Name="PART_SelectedContentHost" 
                                Content="{TemplateBinding SelectedContent}" 
                                ContentTemplate="{TemplateBinding SelectedContentTemplate}" 
                                ContentStringFormat="{TemplateBinding SelectedContentStringFormat}" 
                                ContentSource="SelectedContent" 
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="TabStripPlacement" Value="Bottom">
                            <Setter TargetName="PART_Panel" Property="Grid.Row" Value="1" />
                            <Setter TargetName="PART_Content" Property="Grid.Row" Value="0" />
                            <Setter TargetName="RowDefinition0" Property="Height" Value="*" />
                            <Setter TargetName="RowDefinition1" Property="Height" Value="Auto" />
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Left">
                            <Setter TargetName="PART_Panel" Property="Grid.Row" Value="0" />
                            <Setter TargetName="PART_Panel" Property="Grid.Column" Value="0" />
                            <Setter TargetName="PART_Content" Property="Grid.Row" Value="0" />
                            <Setter TargetName="PART_Content" Property="Grid.Column" Value="1" />
                            <Setter TargetName="ColumnDefinition0" Property="Width" Value="Auto" />
                            <Setter TargetName="ColumnDefinition1" Property="Width" Value="*" />
                            <Setter TargetName="RowDefinition0" Property="Height" Value="*" />
                            <Setter TargetName="RowDefinition1" Property="Height" Value="0" />
                        </Trigger>
                        <Trigger Property="TabStripPlacement" Value="Right">
                            <Setter TargetName="PART_Panel" Property="Grid.Row" Value="0" />
                            <Setter TargetName="PART_Panel" Property="Grid.Column" Value="1" />
                            <Setter TargetName="PART_Content" Property="Grid.Row" Value="0" />
                            <Setter TargetName="PART_Content" Property="Grid.Column" Value="0" />
                            <Setter TargetName="ColumnDefinition0" Property="Width" Value="*" />
                            <Setter TargetName="ColumnDefinition1" Property="Width" Value="Auto" />
                            <Setter TargetName="RowDefinition0" Property="Height" Value="*" />
                            <Setter TargetName="RowDefinition1" Property="Height" Value="0" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="{x:Type TabControl}" TargetType="{x:Type TabControl}" BasedOn="{StaticResource Style.TabControl.Horizontal}">
        <Setter Property="MinHeight" Value="125"/>
        <Setter Property="Padding" Value="10"/>
    </Style>
</ResourceDictionary>